package agent.ccs
import org.scalatest.fixture.FlatSpec
import org.scalatest.matchers.ShouldMatchers
import org.scalatest.OneInstancePerTest
import org.scalatest.matchers.ShouldMatchers

class CCSParserTest extends CCSParser with FlatSpec with ShouldMatchers {
  override def withFixture(test: OneArgTest) {
  }
  
  def trivialNameTest(input: String) = {
    apply(input).agentString should equal(input)
  }
  
  def classTest(input: String, classType: Class[_]) {
    apply(input).privAgent.getClass() should equal(classType)
  }
  
  // Verifying class results.
  classTest("0", classOf[PNil])
  classTest("A", classOf[PVar])
  classTest("a.b.A", classOf[PPrefix])
  classTest("A|B", classOf[PParallel])
  classTest("A+B", classOf[PSSum])

  classTest("A|B|C", classOf[PParallel])
  classTest("A+B+C", classOf[PSSum])

  classTest("A      |B  |    C", classOf[PParallel])
  
  // Naming tests, parser is stripping whitespace chars so these should not matter other than
  // for matching the print form.
  trivialNameTest("0")
  trivialNameTest("A")
  trivialNameTest("a.b.A")
  trivialNameTest("A | B")
  trivialNameTest("A + B")

  trivialNameTest("A | B | a.b.0 | C")
}


